﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Windows.Data;
using System.Windows.Input;
using DeSleeper.Client.Framework;
using DeSleeper.Library;
using DeSleeper.Library.PowerManagement;

namespace DeSleeper.Client.SystemConfig
{
    public class SystemViewModel : ViewModelBase
    {
        public EnableWakeOnLanCommand EnableWakeOnLanCommand { get; private set; }
        public SetSleepStateCommand SetSleepStateCommand { get; private set; }

        public ObservableCollection<WakeOnLanNetworkInterface> Interfaces { get; private set;}
        public PowerScheme PowerScheme { get; private set; }

        public SystemViewModel()
        {
            EnableWakeOnLanCommand = new EnableWakeOnLanCommand();
            SetCommandEvents(EnableWakeOnLanCommand);

            SetSleepStateCommand = new SetSleepStateCommand();
            SetCommandEvents(SetSleepStateCommand);

            Interfaces = new ObservableCollection<WakeOnLanNetworkInterface>();
            InitializeCollectionAsync(WakeOnLanNetworkInterface.GetAllRelevantInterfaces, Interfaces);

            InitializePropertyAsync(PowerScheme.GetCurrent,
                                    result => PowerScheme = result,
                                    "PowerScheme");
        }
    }
}
